package com.hongpu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hongpu.domain.HpProjectWorkPay;
import com.hongpu.domain.HpProjectWorkPayList;
import com.hongpu.dto.ExpensesDto;
import com.hongpu.dto.IncomeDto;
import com.hongpu.dto.TotalReceiptsDto;
import com.hongpu.vo.HpProjectWorkPayListVo;
import com.hongpu.vo.HpProjectWorkPayVo;
import com.hongpu.vo.InvoiceTaxAmountStatisticsVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
* @author Michael zhang
* @description 针对表【hp_project_work_pay_list(项目的回款与支出明细)】的数据库操作Mapper
* @createDate 2025-04-25 21:05:56
* @Entity generator.domain.HpProjectWorkPayList
*/
@Mapper
public interface HpProjectWorkPayListMapper extends BaseMapper<HpProjectWorkPayList> {
    /**
     * 分页
     */

    /**
     * 分页
     */
    public IPage<HpProjectWorkPayListVo> selectPageInCome(@Param("page") IPage<?> page,@Param("projectName") String projectName);
    public IPage<HpProjectWorkPayListVo> selectPageExpenses(@Param("page") IPage<?> page,@Param("projectName") String projectName);

    public List<HpProjectWorkPayListVo> selectListInCome(@Param("projectName") String projectName);
    public List<HpProjectWorkPayListVo> selectListExpenses(@Param("projectName") String projectName);

 //   public IPage<HpProjectWorkPayListVo> selectPage(@Param("ipage") IPage<?> ipage, @Param("projectWorkPayId") Long projectWorkPayId,@Param("incomeAndExpenditureTypes") String incomeAndExpenditureTypes);

    /**
     *   新增数据之前，先根据projectWorkPayId清空数据
     */
    public int deleteByProjectWorkPayId(Long projectWorkPayId);

    public IncomeDto getIncomeDto(@Param("projectWorkPayId") Long id);
    public ExpensesDto getExpensesDto(@Param("projectWorkPayId") Long id);

    /**
     * 在 收支记录列表 中点击 项目名称 或 已支付 时查询详情
     * @param projectName
     * @param incomeAndExpenditureTypes
     * @return
     */
    public List<HpProjectWorkPayList> selectHpProjectWorkPayListByProjectName(@Param("projectName") String projectName,@Param("incomeAndExpenditureTypes") String incomeAndExpenditureTypes);

    /**
     * 统计 合同中约定的每次回款额
     * @param projectWorkPayId
     * @param id
     * @return
     */
    public BigDecimal getContractAmountSum(@Param("projectWorkPayId") Long projectWorkPayId, @Param("id") Long id);


    /**
     * 当明细数据修改时，同时修改未回款数据
     */
    public int updateUnpaid(@Param("id") Long id,@Param("unpaid") BigDecimal unpaid);

    /**
     * 根据回款项目的ID查询支出的项目对象
     */
    public HpProjectWorkPay getHpProjectWorkPayByProjectWorkPayId(@Param("projectWorkPayId") Long projectWorkPayId);
    /**
     * 根据 projectWorkPayId 查询收入合同金额
     */
    public BigDecimal getInTotalContractAmount(@Param("projectWorkPayId") Long projectWorkPayId);


    /**
     *  根据 projectWorkPayId 和incomeAndExpenditureTypes 查询付款合同总额、已收款总额、未收款总额
     */
    public HpProjectWorkPayVo getPaidSum(@Param("projectWorkPayId") Long projectWorkPayId);

    public HpProjectWorkPayVo getUnPaidSum(@Param("projectWorkPayId") Long projectWorkPayId);

    /**
     * 收款合计
     */
    public TotalReceiptsDto totalReceipts(@Param("incomeAndExpenditureTypes") String incomeAndExpenditureTypes,@Param("projectName") String projectName);

    /**
     * hp_project_work_pay_list 表中 it_has_been_invoiced 字段设置为 0
     */
    public boolean updateItHasBeenInvoiced(@Param("payListId") Long payListId,@Param("itHasBeenInvoiced") Integer itHasBeenInvoiced,@Param("updateBy") Long updateBy);

    /**
     *  1、查询合同总金额
     */
    public BigDecimal selectTotalContractAmount(@Param("projectWorkPayId") Long projectWorkPayId);

    /**
     *  2、查询已收款金额
     */
    public BigDecimal totalPaid(@Param("projectWorkPayId") Long projectWorkPayId,@Param("id") Long id);


    /**
     * 税额统计
     * @param projectWorkPayId   项目的收款或付款数据ID
     * @param incomeAndExpenditureTypes  项目收支类型：0收入 1支出
     * @return
     */
    public List<InvoiceTaxAmountStatisticsVo> collectionTaxStatistics(@Param("projectWorkPayId") Long projectWorkPayId,@Param("incomeAndExpenditureTypes") String incomeAndExpenditureTypes);
}




